package utils.utils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @Author: sangbowei
 * @Description:
 * @Date: 2018/8/28 20:00
 */
public class SortUtils {

	public static void main(String[] args) {

		List<Student> studentList = new ArrayList<>();
		studentList.add(new Student(1,"aaa",1));
		studentList.add(new Student(21,"212121",4));
		studentList.add(new Student(12,"121212",3));
		studentList.add(new Student(7,"7777",2));

		studentList.sort(Comparator.comparing(Student::getId).reversed());

//		Collections.sort(studentList, (Comparator) (a, b) -> {
//			int one = ((Student) a).getId();
//			int two = ((Student) b).getId();
//			return one - two;
//		});

		System.out.println(studentList);
	}

	static class Student{

		private int id;
		private String name;
		private int age;

		public Student(){}

		public Student(int id,String name,int age){
			this.id = id;
			this.name = name;
			this.age = age;
		}

		public int getId() {
			return id;
		}

		public void setId(int id) {
			this.id = id;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public int getAge() {
			return age;
		}

		public void setAge(int age) {
			this.age = age;
		}
	}
}
